import request from '@/utils/request'

export function loginByUsername(data) {
  return request({
    url: 'sys/login',
    method: 'post',
    data
  })
}

export function logout() {
  return request({
    url: 'sys/logout',
    method: 'post'
  })
}

export function getUserInfo(token) {
  return request({
    url: 'sys/user/info',
    method: 'get',
    params: { token }
  })
}

export function getMenu() {
  return request({
    url: 'sys/menu/nav',
    method: 'get'
  })
}

export function password(data) {
  return request({
    url: 'personal/updatePassword',
    method: 'post',
    data
  })
}

export function updateUserName(data) {
  return request({
    url: 'personal/updateUsername',
    method: 'post',
    data
  })
}

/**
 * 获取uuid
 */
export function getUUID() {
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
    return (c === 'x' ? (Math.random() * 16 | 0) : ('r&0x3' | '0x8')).toString(16)
  })
}
